/*
 * The MIT License
 *
 * Copyright 2013-2014 Florian Barras.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package jeo.math.calculator.thread;

import java.util.Map;
import jeo.common.io.IOManager;
import jeo.common.structure.Triplet;
import jeo.common.thread.Report;
import jeo.common.thread.WorkQueue;
import jeo.common.thread.Worker;
import jeo.math.calculator.model.Element;
import jeo.math.calculator.process.ExpressionHandler;

public class ExpressionParser
	extends
	Worker<ExpressionParser, Triplet<Element, String, Map<String, Element>>, Element>
{
	public ExpressionParser(final WorkQueue<ExpressionParser, Triplet<Element, String, Map<String, Element>>, Element> workQueue)
	{
		super(workQueue);
	}

	@Override
	public Report<Element> processInput(final Triplet<Element, String, Map<String, Element>> input)
	{
		return ExpressionHandler.parseExpression(input.getFirst(), input.getSecond(), input.getThird());
	}

	@Override
	public ExpressionParser copy()
	{
		IOManager.printDebug("Create copy of " + ExpressionParser.class.getSimpleName());
		return new ExpressionParser(workQueue);
	}
}
